import sys
import re
if __name__ == "__main__":
    handlers = sys.stdin
    friend_pairs = []
    oneselfs = []
    friend = []
    oneselfs_friend = {}
    for hands in handlers:
        hand = hands.strip()
        if hand != '' and len(hand) == 1:
            oneself = hand
            oneselfs.append(oneself)
        if hand != '' and len(hand) > 1:
            pairs_set = []
            for ha in hand:
                if re.match('[a-zA-Z]',ha):
                    pairs_set.append(ha)
            friend_pairs.append(pairs_set)        
    # print(friend_pairs,oneselfs)
    # for key in friend_pairs:
    #     print(key)
    for i in range(len(oneselfs)-1):
        if oneselfs[i+1]:
            for j in range(i+1,len(oneselfs)):
                oneselfs_key = oneselfs[i]+oneselfs[j]
                oneselfs_friend[oneselfs_key] = None
    # print(oneselfs_friend)
                friends = []
                for p in range(len(friend_pairs[i])):
                    for t in range(len(friend_pairs[j])):
                        if friend_pairs[i][p] == friend_pairs[j][t]:
                            friends.append(friend_pairs[i][p])
                oneselfs_friend[oneselfs_key] = friends
    print(oneselfs_friend)


                #     if friend_pairs[i][p] != oneselfs[i] or friend_pairs[i] != oneselfs[j]:
                #         print(friend_pairs[i][j])    
                    #    print('你好')
                    # else:
    #                 friends = []
    #                 if friend_pairs[i][i] == friend_pairs[j][p]:
    #                     friends.append(friend_pairs[i][p])
    #             if friends:
    #                 oneselfs_friend[oneselfs_key] = friends
    # print(oneselfs_friend)                         
                # print(oneselfs_key)

            # print(oneselfs[i]+oneselfs[i+1])
            # oneselfs_key = oneselfs[i]+oneselfs[i+1]
            # oneselfs_friend[oneselfs_key] = None
            # for j in range(min(len(friend_pairs[i]),len(friend_pairs[i+1]))):
            #     if (friend_pairs[i][j] != oneselfs[i] and friend_pairs[i][j] != oneselfs[i+1]) and 
            #     (friend_pairs[i+1][j] != oneselfs[i] and friend_pairs[i+1][j] != oneselfs[i+1]):

                



                

           
            
